#include "mount.h"

static struct semaphore_t mount_sema;

/*
**	、发送异步通知信息
*/
static void sync_umount(){
	
}

/*
**	while blockdevice all ready,do_mount() could be callback 
*/
int do_mount(const char *name,int flag){
	/*判断系统是否支持该文件系统类型*/
	
	/*判断相关信息是否完整*/
}



static int do_umount(struct vfs_mount *mnt,int umount_root,int flag){
	struct super_block *sb = mnt->mnt_sb; 
	if(sb->mnt_sb == current->fs->rootmnt){//如果需要卸载的是当前正在使用的文件系统
		return -ENODEV;
	}
	spin_lock(&dcache_lock);//wait until spin_unlock happen
	/*将设备相关资源进行释放*/
	
	sync_umount();/*检测是否还有资源被占用，若是，则发送异步通知*/
	spi_unlock(&dcache_lock);
	return 0;
}


long sys_umount(char *name,int flag){
	/*name args was userspace*/
	char *kname = getname(name);
	struct nameidata nd;
	int ret = 0;
	if(IS_ERROR(kname))
		goto out;

	if(path_init(kname,LOOKUP_POSITIVE|LOOKUP_FOLLOW, &nd))
		ret = path_walk(kname,&nd);
	putname(kname);
	if(ret)
		goto out;

	down(&mount_sema);
	ret = do_umount(nd.mnt,0,flag);
	return ret;
out:
	return -ENODEV;
}










